/**
 * 详情对话框
 */
var CbCustomerCompanyInfoDlg = {
    data: {
        id: "",
        status: "",
    }
};

layui.use(['form', 'admin', 'ax','laydate','upload','formSelects', 'layedit'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layedit = layui.layedit;






































    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/api/customer_company/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    var introduction = decodeURIComponent(result.data.introduction);
    result.data.introduction = introduction;
    var logo = Feng.ctxPath+'/api/oss/stream_file?objectName='+result.data.logo;
    $('#filePreview').attr('src', logo); //图片链接（base64）
    form.val('cbCustomerCompanyForm', result.data);

    var index_introduction = layedit.build('introduction',
        {
            tool: [""],
            // height: 600
        }); //建立编辑器

    $("#LAY_layedit_1").contents().find("body[contenteditable]").prop("contenteditable", false);
    layedit.setContent(index_introduction, introduction);//赋值

    //表单提交事件
    form.on('submit(reviewPass)', function (data) {
        data.field.status = 2;
        data.field.introduction = encodeURIComponent(introduction);
        var ajax = new $ax(Feng.ctxPath + "/api/customer_company/checkItem", function (data) {
            Feng.success("审核成功！");
            window.location.href = Feng.ctxPath + '/api/customer_company'
        }, function (data) {
            Feng.error("审核失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
    form.on('submit(reviewDown)', function (data) {
        data.field.status = 3;
        var ajax = new $ax(Feng.ctxPath + "/api/customer_company/checkItem", function (data) {
            Feng.success("审核成功！");
            window.location.href = Feng.ctxPath + '/api/customer_company'
        }, function (data) {
            Feng.error("审核失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
});